<?php
session_start();
require_once("../include/db.php");
require_once("member.common.php");
require_once("../include/head.php");
?>
<?php $xajax->printJavascript("/");
?>
<script language="javascript">
		function submitSignup()
		{
			xajax.$('submit').disabled=true;
			var mailing=document.getElementsByName('mailing');
			for (var i=0;i<mailing.length;i++)
			{
				if (mailing[i].checked)
				{
			     xajax_uwannamail(mailing[i].value);
				}
			}
			return false;
		}
</script>		
<DIV id=gNavBottom>
<DIV id=searchDiv>
<FORM id=searchForm name=searchForm action=result.php method=post>
	<INPUT class=searchField type="text" tabIndex=10000 maxLength=128 name=search_query> &nbsp; 
	<INPUT type=submit value=Search name=search>
</FORM>
</DIV>
</DIV>
<table width="100%">
    <tr>
    	<td width="15%" valign="top">
          My account option
          <UL>
           <li><a href="mailinglist.php">My maillist</a></li>
          </UL>    		
   	  </td>    
    	<td width="85%">
    		<h1>Search Company Result</h1>
    		<hr>
        <?php
           	$sql="select * from company where companyname like '%".$_POST["search_query"]."%' or products like '%".$_POST["search_query"]."%'";
           	$result=mysql_query($sql,getconnection());
           	while ($row=mysql_fetch_array($result))
           	{
           		echo "<table width='100%' border='0'>";
           		echo "    <tr>";
           		echo "        <td width=100><h1>".$row['companyname']."</h1><img src='../".$row['logo']."' width='80' /></td>";
           		echo "        <td>";
              $sqlmailing="select * from mailing where companyid=".$row['id'];
           	  $resultmailing=mysql_query($sqlmailing,getconnection());
           	  while ($mailing=mysql_fetch_array($resultmailing))
           	  {
           	  	 echo "<input type='checkbox' name='mailing' value='".$mailing['id']."' />".$mailing['name']."&nbsp;&nbsp;&nbsp;&nbsp;".$mailing['fromemail']."<br>";
           	  }
           		echo "       </td>";
           		echo "    </tr>";
           		echo "</table>";
           		echo "</hr>";
           	}
        ?>    		
       	<input type='button' name='submit' value='wannamail' onclick="submitSignup();" />   	  
   	    </td>    
    </tr>
  </table>
<?php
require("../include/foot.php");
?>